<template>
    <div class="listDiv pd20">
        <div class="searchDiv">
            <span class="btn search mb10" @click="obj.req.currentpage=1;init()">查询</span>
        </div>
        <div class="table" id="tb">
            <ul class="head">
                <li class="li100 liflex fixed ls">文件名称</li>
                <li class="li150">文件编号</li>
                <li class="liflex">承办单位</li>
                <li class="liflex">关键词</li>
                <li class="li260">简介</li>
                <li class="litime"><HeadSort text="录入时间" v-model:sort="obj.req.sort" :index="1" @sortClick="obj.req.currentpage=1;init()" /></li>
                <li class="liaction li110">操作</li>
            </ul>
            <div class="body">
                <ul v-for="x in obj.ary" :key="x">
                    <li class="li100 liflex fixed ls"><span class="lineOne">{{x.name}}</span></li>
                    <li class="li150 flex-center"><span class="lineOne">{{x.code}}</span></li>
                    <li class="liflex flex-center">{{x.dept_name}}</li>
                    <li class="liflex flex-center">{{ x.keyword }}</li>
                    <li class="li260">
                        <el-tooltip
                                    class="box-item"
                                    effect="dark" :disabled="x.synopsis.length<19"
                                    :content="x.synopsis"
                                    placement="top-start"
                                >
                                <template #content><div style="width: 600px;">{{ x.synopsis }}</div></template>
                            <span class="lineOne">{{x.synopsis.substring(0,20)}}</span>
                        </el-tooltip></li>
                    <li class="litime flex-center">{{ x.intime }}</li>
                    <li class="liaction li110 flex-center">
                        <u @click.prevent="edit(x)">查看</u>
                        <u @click.prevent="obj.showLog_id=x.file_id;obj.showLog_name=x.name;">日志</u>
                        <DelConfirm @yesClick="del(x)" />
                    </li>
                </ul>
            </div>
        </div>
        <ElConfigProvider :locale="locale">
            <el-pagination layout="total, prev, pager, next, jumper" background :total="obj.req.count" :page-size="obj.req.pagesize" v-model:currentPage="obj.req.currentpage" @current-change="init()" />
        </ElConfigProvider>
        <div v-if="obj.showLog_id" class="showLogbox">
            <ReadFileLog :id="obj.showLog_id" :name="obj.showLog_name" :tags="['分享列表','承办进展']" @close="obj.showLog_id=false" />
        </div>
    </div>
</template>

<script setup>
    import { reactive,getCurrentInstance,onMounted,onActivated } from 'vue'
    import DelConfirm from '@/components/del_confirm.vue'
    import DateRange from '@/components/date_range.vue'
    import HeadSort from '@/components/head_sort.vue'
    import ReadFileLog from '../readFileLog.vue'

    import locale from "element-plus/es/locale/lang/zh-cn";
    let { proxy } = getCurrentInstance()

    let obj = reactive({
        showLog_id: false,
        showLog_name: '',
        ary:[],
        req:{
            "currentpage": 1,
            "pagesize": 10,
            count: 0,
        },
        companys: []
    })

    onActivated(async()=>{
        obj.companys = await proxy.$setting.getcompanys()
        init()
    })

    const init=()=>{
        proxy.$ajax({
            url: '/user/file/share/list',
            data: obj.req,
            bfLoading: true
        }).then(d => {
            if(d.success){
                obj.ary = d.msg.list
                obj.req.count = d.msg.count
            }
        }).catch(() => { })
    }

    let add = () => {
        proxy.routerPushMixin("/sharefileEdit",{id:0})
    }
    let edit = x => {
        proxy.routerPushMixin("/sharefileEdit",{id:x.file_id,dept_name:x.dept_name,user_name:x.user_name,codetime:x.codetime})
    }

    let del = x => {
        proxy.$ajax({
            url: '/user/file/share/delete',
            data: { file_id: x.file_id },
            bfLoading: true
        }).then(d => {
            if(d.success){
                proxy.elMessageMixin("删除分享成功", 'success')
                init()
            }else{
                proxy.elMessageMixin(d.err, 'error')
            }
        }).catch(() => { })
    }
</script>

<style scoped>
</style>